// 防抖立即执行
const debounce = (fn, delay) => {
  let timer = null
  let flag = true
  return () => {
    clearTimeout(timer)
    if (flag) {
      fn.apply(this)
      flag = false
    }
    timer = setTimeout(() => {
      flag = true
    }, delay)
  }
}

export { debounce }
